<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件绑定</title>
    <style>
        #ad{
            width: 200px;
            height: 200px;
            background:#caf;
        }
    </style>
</head>
<body>
    <div id="root"> </div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">

        // function test(){
        //     alert('今天天气是真的不错!!!');
        // }

        //创建虚拟DOM对象
        class App extends React.Component{
            render(){
                return <div>
                        <button onClick={this.test}>点击</button>
                        <div id="ad" onMouseOver={this.mouseover} onMouseOut={this.mouseout}></div>
                    </div>
            }

            //声明一个方法
            test(){
                alert('今天天气是真的不错!!!');
            }

            mouseover(){
                alert('鼠标放到了我的身上');
            }

            mouseout(){
                alert('别走啊!!');
            }
        }

        ReactDOM.render(<App />, document.querySelector("#root"));
    </script>
</body>
</html>